import * as Blockly from 'blockly/core';
import Variables from './others/variables';
import { Lua } from './generators/lua_generator';
import {ZhHansBlocks, ZhHansCatgories} from './language/zh-hans';
import {ZhHantMsg, ZhHantCatgories} from './language/zh-hant';
import {EnBlocks, EnCatgories} from './language/en';

import * as luaControlBlocks from './blocks/control';
import * as luaInoutBlocks from './blocks/inout';
import * as luaLogicBlocks from './blocks/logic';
import * as luaMathBlocks from './blocks/math';
import * as luaProceduresBlocks from './blocks/procedures';
import * as luaTextBlocks from './blocks/text';
import * as luaVariablesBlocks from './blocks/variables';

import * as luaControlGenerators from './generators/control';
import * as luaInoutGenerators from './generators/inout';
import * as luaLogicGenerators from './generators/logic';
import * as luaMathGenerators from './generators/math';
import * as luaProceduresGenerators from './generators/procedures';
import * as luaTextGenerators from './generators/text';
import * as luaVariablesGenerators from './generators/variables';

import './css/color.css';

Blockly.Lua = Lua;
Object.assign(Blockly.Variables, Variables);

// 载入语言文件
Object.assign(Blockly.Lang.ZhHans, ZhHansBlocks);
Object.assign(Blockly.Lang.ZhHant, ZhHantMsg);
Object.assign(Blockly.Lang.En, EnBlocks);
Object.assign(Blockly.Lang.ZhHans.MSG, ZhHansCatgories);
Object.assign(Blockly.Lang.ZhHant.MSG, ZhHantCatgories);
Object.assign(Blockly.Lang.En.MSG, EnCatgories);

// 载入图形化模块外观定义文件
Object.assign(
    Blockly.Blocks,
    luaControlBlocks,
    luaInoutBlocks,
    luaLogicBlocks,
    luaMathBlocks,
    luaProceduresBlocks,
    luaTextBlocks,
    luaVariablesBlocks
);

// 载入图形化模块代码生成定义文件
Object.assign(
    Blockly.Lua.forBlock,
    luaControlGenerators,
    luaInoutGenerators,
    luaLogicGenerators,
    luaMathGenerators,
    luaProceduresGenerators,
    luaTextGenerators,
    luaVariablesGenerators
);